package com.guoyh.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.guoyh.bilcommon.R
import com.guoyh.baseutils.mylog.Loger
import com.guoyh.ext.loadPicH
import com.guoyh.baseutils.entity.common.BaseBannerBean
import com.xuexiang.xui.widget.layout.XUILinearLayout
import com.youth.banner.adapter.BannerAdapter

/**
 * @CreateDate: 6/19/21 3:38 PM
 * @Author: guoyh
 * @Description:  常规 Banner适配器
 */
class SimpleBannerAdapter<T>( datas: MutableList<out BaseBannerBean<T>>) :
    BannerAdapter<BaseBannerBean<T>, SimpleBannerAdapter.SimpeleBannerViewHolder>(datas) {

    override fun onCreateHolder(parent: ViewGroup, viewType: Int): SimpeleBannerViewHolder {
        return SimpeleBannerViewHolder(
            LayoutInflater.from(parent.context).inflate(
                R.layout.libcommon_item_banner,
                parent,
                false
            )
        )

    }

    override fun onBindView(
        holder: SimpeleBannerViewHolder,
        data: BaseBannerBean<T>,
        position: Int,
        size: Int
    ) {
        Loger.dd(data.getBannerPath())

//        holder.group.setRadius(10.dp)
        if (data.getBannerType()==1){
            holder.img.setImageDrawable(data.getBannerDrawable())
        }else if (data.getBannerType()==0){
            holder.img.loadPicH(data.getBannerPath()!!)
        }

    }

    class SimpeleBannerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val img: ImageView = view.findViewById(R.id.itemBannerImg)
        val group: XUILinearLayout = view.findViewById(R.id.itemBannerGroup)

    }


}